function getDatas(claName, dataId){
    $.ajax({
		url : config.functionPath + claName + "S.php?action=getTableData",
		dataType: "json" , 
		type: 'POST',
		cache : false,
		data : { dataId : dataId },
		beforeSend :function (){ showWait('資料取得中...'); } 
	}).done(	function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		modifyDatas = result['data'];
		dataInside();
	}).fail(function (error){	
		hideWait(); alert(error.responseText); 
	}); 	
}

function insertDatas(claName){
	if(!confirm("確認新增?")){return;}
	$.ajax({
		url : config.functionPath + claName + "S.php?action=insert",
		dataType: "json" ,
		type: 'POST',
		cache : false,
		data : { datas : modifyDatas},
		beforeSend :function (){ showWait('資料新增中...'); } 
	}).done(	function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		location.reload();
	}).fail(function (error){	
		hideWait(); alert(error.responseText); 	
	}); 
	
}

function updateDatas(claName){
	if(!confirm("確認修改?")){return;}
	$.ajax({
		url : config.functionPath + claName + "S.php?action=update",
		dataType: "json" ,
		type: 'POST',
		cache : false,
		data : { datas : modifyDatas},
		beforeSend :function (){ showWait('資料修改中...'); } 
	}).done(function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		location.reload();
	}).fail(function (error){	
		hideWait(); alert(error.responseText); 	
	}); 
}

function isDeleteDatas(claName){
	if(!confirm("確認刪除?")){return;}
	$.ajax({
		url : config.functionPath + claName + "S.php?action=isDelete",
		dataType: "json" ,
		type: 'POST',
		cache : false,
		data : { datas : modifyDatas},
		beforeSend :function (){ showWait('資料刪除中...'); } 
	}).done(function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		location.reload();
	}).fail(function (error){	
		alert(error.responseText); 
	}); 
}

function deleteDatas(claName, dataId){
	if(!confirm("確認刪除?")){return;}
	$.ajax({
		url : config.functionPath + claName + "S.php?action=delete",
		dataType: "json" ,
		type: 'POST',
		cache : false,
		data : { id : dataId },
		beforeSend :function (){ showWait('資料刪除中...'); } 
	}).done(function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		location.reload();
	}).fail(function (error){	
		hideWait();
		alert(error.responseText); 
	}); 
}

function addSelectOption(claName, funName, selcetName, valueName, textName){
	$.ajax({
		url : config.functionPath + claName + "S.php?action="+funName,
		dataType: "json" , 
		type: 'POST',
		cache : false,
		data : {},
		beforeSend :function (){ showWait('資料取得中...'); } 
	}).done(function(result){	
		hideWait();
		if(!checkAjaxResult(result)){return;}
		addOptions(selcetName, result['data'], valueName, textName); 
	}).fail(function (error){		
		hideWait(); alert(error.responseText); 	
	}); 
}

function addDatepicker(inputName){
	$("#"+inputName).datepicker({
    	dateFormat : "yy-mm-dd", changeMonth : true, changeYear : true ,
    	dayNamesMin: ['日','一','二','三','四','五','六'],
    	monthNamesShort: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
    });
}

function addImgUpload(imgId, buttonId){
	fileImgUpload(buttonId, function(file, data, response) {
		$("#"+imgId).attr("src", data);
	});
}
